<%--
  Created by IntelliJ IDEA.
  User: Elle
  Date: 2023/5/15
  Time: 9:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户列表</title>
</head>
<body>
<div>
    <a href="${pageContext.request.contextPath}/user/toadd">新增用户</a>
</div>
<%--条件--%>
<div>
    <form action="" method="post" id="myform">
        <input type="hidden" name="currentPage" value="1"/>
        角色名称:<input type="text" name="roleName" >
        <input type="submit" value="搜索">
    </form>
</div>
<table>
    <tr>
        <td>编号</td>
        <td>code</td>
        <td>名称</td>
        <td>操作</td>
    </tr>
    <c:forEach var="tmp" items="${roleList}">
        <tr>
            <td>${tmp.id}</td>
            <td>${tmp.code}</td>
            <td>${tmp.roleName}</td>
            <td>
                <a href="${pageContext.request.contextPath}/role/delete/${tmp.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<%--分页--%>
<c:set var="currentPage" value="1" scope="page"/>
<c:set var="totalPage" value="4" scope="page"/>
<c:set var="totalSize" value="20" scope="page"/>
<div>
    ${currentPage}/${totalPage}&nbsp;&nbsp;，共${totalSize}条数据
    <a href="javascript:page(1)">首页</a>
    <a href="javascript:page( ${currentPage-1})">上一页</a>
    <a href="javascript:page( ${currentPage+1})">下一页</a>
    <a href="javascript:page(${totalPage})">尾页</a>
</div>
<script>
    function page(pageIndex){
        $("#myform>[name=currentPage]").val(pageIndex); //修改表单中当前页的数据
        //页面跳转
        $("#myform").submit();//提交待条件的分页请求
    }
</script>
</body>
</html>
